<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'basicdata.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item>供应商管理</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
    <div class="departments">
      <div class="card">
        <div class="card-title">
          <span>供应商类别</span>
        </div>
        <div class="fitter mt-3">
          <input dTextInput placeholder="请输入" name="searchValue" (input)="searchMaterialCategory($event)" />
        </div>
        <div class="card-body ">
          <d-tree #basicTree [tree]="displayTreeData"
            [treeNodeTitleKey]="'supplyClassName'" [treeNodeChildrenKey]="'subSupplyClasses'"
            (afterTreeInit)="afterTreeInit($event)" (nodeSelected)="nodeSelected($event)">
          </d-tree>
        </div>
        <div class="card-footer d-flex  align-items-bottom justify-content-center">
          <d-button bsStyle="common"bsSize="sm" (btnClick)="creatType()">
            新增
          </d-button>
          <d-button bsStyle="common" (btnClick)="editType()" bsSize="sm" [ngClass]="{'disabled':!this.supplierTypeId}">
            编辑
          </d-button>
          <d-button bsStyle="danger"  (btnClick)="deleteType()" bsSize="sm" [ngClass]="{'disabled':!this.supplierTypeId}">
            删除
          </d-button>
        </div>
      </div>
    </div>
    <div class="employs-box">
      <div class="card">
        <div class="card-header">
          <div class="d-input">
            <div class="inputIn">
              <input dTextInput style="width: 180px;" [error]="false" placeholder="供应商编号/名称"
                [(ngModel)]="filter.SearchTerm" name="SearchTerm">
              <d-select style="width: 180px;" [options]="statusoptions" [(ngModel)]="filter.SearchStatus"
               placeholder="状态"></d-select>
            </div>
            <div class="d-submit">
              <d-button id="primaryBtn" style="margin-left: 8px" (click)="search2()"><i
                  class="icon icon-filter-o me-2"></i>查询</d-button>
              <d-button bsStyle="common" (btnClick)=" reset()"> <i class="icon icon-refresh me-2"></i>重置</d-button>
            </div>
          </div>
        </div>
        <div class="btn-group">
          <d-button bsStyle="primary" (btnClick)="addSupplier()"> <i class="icon icon-add me-2"></i>新增</d-button>
          <d-button bsStyle="success" (btnClick)="enable()"><i class="icon icon-right me-2"></i>启用</d-button>
          <d-button bsStyle="warning" (btnClick)="disable()"><i class="icon icon-error me-2"></i>禁用</d-button>
          <d-button bsStyle="danger" (btnClick)="deleteSupplier()"><i class="icon icon-delete me-2"></i>删除</d-button>
          <div class="dDropDown" dDropDown [trigger]="'hover'">
            <input type="file" #fileInput style="display: none" (change)="onFileSelected($event)">
            <d-button bsStyle="common" class="devui-dropdown-origin" (btnClick)="onButtonClick()">
              导入
              <span class="icon-select-arrow"></span>
            </d-button>
            <ul dDropDownMenu class="devui-dropdown-menu devui-scrollbar" role="menu">
              <li role="menuitem" (click)="DownloadSupplierFileModel()">
                <a dDropDownMenuItem>下载模板</a>
              </li>
            </ul>
          </div>
          <d-button bsStyle="common" (btnClick)="DownloadSupplierFile()"><i class="icon-copy-new me-2"></i>导出</d-button>

        </div>
        <div class="list-content">
          <d-data-table [lazy]="true" [dataSource]="tabledata" [scrollable]="true" [fixHeader]="true"
            [tableWidthConfig]="tableWidthConfig" (checkAllChange)="getCheckedRows()"
            (rowCheckChange)="getCheckedRows()" [tableOverflowType]="'auto'"  [resizeable]="true"
            [colDraggable]="true">
            <thead dTableHead [checkable]="true">
              <tr dTableRow>
                <th dHeadCell [fixedLeft]="'40px'">
                  操作
                </th>
                <th dHeadCell [fixedLeft]="colOption.fixedLeft " *ngFor="let colOption of dataTableOptions.columns">{{
                  colOption.header }}</th>
              </tr>
            </thead>
            <tbody dTableBody>
              <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex" let-nestedIndex="nestedIndex">
                <tr dTableRow>
                  <td dTableCell [fixedLeft]="'0px'">
                    <d-checkbox [disabled]="false" [showAnimation]="true" [showGlowStyle]="false"
                      [ngModelOptions]="{ standalone: true }" [ngModel]="rowItem.$checked" dTooltip
                      (ngModelChange)="onRowCheckChange($event, rowIndex, nestedIndex, rowItem)">
                    </d-checkbox>
                  </td>
                  <td dTableCell [fixedLeft]="'40px'">
                    <span class="me-2" (click)="editSupplier(rowItem.supplyId)"><a class="devui-link">编辑</a></span>
                    <span class="me-2" (click)="deleteSupplier(rowItem.supplyId)"><a class="devui-link-danger">删除</a></span>
                  </td>
                  <td dTableCell [rowItem]="rowItem" [fixedLeft]="'150px'" >
                    <span dTooltip [content]="rowItem?.supplyNum">{{rowItem?.supplyNum}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem" [fixedLeft]="'300px'">
                    <span dTooltip [content]="rowItem?.supplyChineseName">{{rowItem?.supplyChineseName}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.supplyShortName">{{rowItem?.supplyShortName}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.supplyEnglishName">{{rowItem?.supplyEnglishName}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.supplyClassName">{{rowItem?.supplyClassName}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.salesmanName">{{rowItem?.salesmanName}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.contactPerson">{{rowItem?.contactPerson}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.phone">{{rowItem?.phone}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="(rowItem?.country || '') + (rowItem?.province || '') + (rowItem?.city || '') +
                      (rowItem?.district || '') + (rowItem?.address || '')">{{(rowItem?.country || '') + (rowItem?.province || '') + (rowItem?.city || '') +
                      (rowItem?.district || '') + (rowItem?.address || '')}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.fax">{{rowItem?.fax}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.email">{{rowItem?.email}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.isInvoicing | booleanToText:'开票'"><d-tag *ngIf="rowItem?.isInvoicing" [tag]="rowItem?.isInvoicing | booleanToText:'开票'"></d-tag></span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.taxRate | percent">{{rowItem?.taxRate | percent}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.collectionPeriodName">{{rowItem?.collectionPeriodName }}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.settlementMethodName">{{rowItem?.settlementMethodName}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.currencyName">{{rowItem?.currencyName}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.isEnable | status">
                      <d-tag
                    [tag]=" rowItem?.isEnable | status"
                    [labelStyle]="rowItem?.isEnable"></d-tag>
                    </span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.remake">{{rowItem?.remake}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.createDate | date :'yyyy-MM-dd'">{{rowItem?.createDate | date :'yyyy-MM-dd'}}</span>
                  </td>
                </tr>
              </ng-template>
            </tbody>
          </d-data-table>
        </div>
        <div class="page-footer">
          <div>
            <p>已选 <span class="underline">{{checkedIds.length}}</span> 条
              <a (click)="cleared()" class="clear">清空</a>
            </p>
          </div>
          <d-pagination [size]="'sm'" [canViewTotal]="true" [canChangePageSize]="true" [canJumpPage]="true"
            [maxItems]="5" [total]="this.pager.total" [pageSizeOptions]="this.pageSizeOptions"
            [(pageSize)]="filter.PageSize" [(pageIndex)]="filter.PageNumber" (pageIndexChange)="pageIndexChange()"
            (pageSizeChange)="pageSizeChange()">
          </d-pagination>
        </div>
      </div>
    </div>
  </div>
</div>
<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
